package info.sswap.ontologies.modularity.owlapi;

import java.net.URI;

import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLEntity;
import org.semanticweb.owlapi.model.OWLOntology;

public class OWLAPIUtils {

	public static OWLEntity uriToOWLEntity(OWLOntology ontology, OWLDataFactory factory, URI termResource) {
		
		IRI termIRI = IRI.create(termResource);
		
		if (ontology.containsClassInSignature(termIRI)) {
			return factory.getOWLClass(termIRI);
		}
		else if (ontology.containsObjectPropertyInSignature(termIRI)) {
			return factory.getOWLObjectProperty(termIRI);
		}
		else if (ontology.containsDataPropertyInSignature(termIRI)) {
			return factory.getOWLDataProperty(termIRI);
		}
			
		return null;
	}
}
